from urllib.parse import urlencode
from urllib.request import Request
from urllib.request import urlopen

if __name__ == '__main__':
    base_url = "https://www.baidu.com/s?"

    word = {
        "wd": "陕西交通职业技术学院"
    }

    wd = urlencode(word)
    # print(wd)

    url = base_url + wd
    print(url)

    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
    }
    req = Request(url=url, headers=headers)

    resp = urlopen(req)
    content = resp.read()
    html = content.decode("utf-8")
    print(html)
